package com.xbongbong.parent.condition;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.FilterConditionsPoJo;
import com.xbongbong.paas.field.LinkConditionPoJo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.businessrule.pojo.BusinessRuleInfoPojo;
import com.xbongbong.pro.condition.pojo.ConditionDTO;
import com.xbongbong.paas.field.LinkInfoPojo;

import java.util.List;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2020/3/3 19:40
 * @since v1.0
 */
public interface ConditionFieldHandler {

    /**
     *
     * @return 字段类型
     */
    List<Integer> fieldType();

    /**
     * 处理本表单字段
     * @param paasFormDataEntity 主要用来取data外的数据
     * @param data 主要是用来放子表单的数据
     * @param fieldAttrEntity 当前表单字段
     * @param targetField 目标表单字段 在关联数据中用于判断
     * @param businessRuleInfoPojo 容器
     * @return
     * @throws XbbException
     */
    Object handlerThisFormField(PaasFormDataEntity paasFormDataEntity, JSONObject data, FieldAttrEntity fieldAttrEntity,  FieldAttrEntity targetField,
                                BusinessRuleInfoPojo businessRuleInfoPojo) throws XbbException;

    /**
     * 处理目标表单
     * @param paasFormDataEntity
     * @param data
     * @param fieldAttrEntity 当前表单字段
     * @param targetField 目标表单字段
     * @param businessRuleInfoPojo
     * @param filterConditionsPoJo
     * @return
     * @throws XbbException
     */
    Object handlerTargetFormField(PaasFormDataEntity paasFormDataEntity, JSONObject data, FieldAttrEntity fieldAttrEntity, FieldAttrEntity targetField,
                                  BusinessRuleInfoPojo businessRuleInfoPojo, FilterConditionsPoJo filterConditionsPoJo) throws XbbException;

    /**
     * 处理固定值
     * @param targetField
     * @param businessRuleInfoPojo
     * @param filterCondition
     * @return
     * @throws XbbException
     */
    Object handlerFixedValue(FieldAttrEntity targetField,
                             BusinessRuleInfoPojo businessRuleInfoPojo, FilterConditionsPoJo filterCondition) throws XbbException;

    /**
     * 处理关联表单
     * @param corpid
     * @param fieldAttrEntity
     * @param relyFieldEntity
     * @param linkInfoPojo
     * @param value
     * @return
     * @author xingxing.xiao
     * @date 2020/07/27 16:33
     */
    Object handlerRelyFormField(String corpid, FieldAttrEntity fieldAttrEntity, FieldAttrEntity relyFieldEntity, LinkConditionPoJo linkConditionPoJo, LinkInfoPojo linkInfoPojo, Object value) throws XbbException;

    /**
     * 处理关联数据的固定值
     * @param corpid
     * @param relyFieldEntity
     * @param linkInfoPojo
     * @param value
     * @author xingxing.xiao
     * @date 2020/07/27 16:30
     */
    Object handlerLinkDataFixedValue(String corpid, FieldAttrEntity relyFieldEntity, LinkInfoPojo linkInfoPojo, Object value) throws XbbException;

    /**
     * 处理系统业务字段
     * @param corpid
     * @param fieldAttrEntity
     * @param relyFieldEntity
     * @param linkConditionPoJo 主要是处理日期时会用到
     * @param value
     * @param linkFormId
     * @param linkBusinessType
     * @return
     * @author xingxing.xiao
     * @date 2020/07/30 19:57
     */
    Object handlerBusinessRelyFormField(String corpid, FieldAttrEntity fieldAttrEntity, FieldAttrEntity relyFieldEntity, LinkConditionPoJo linkConditionPoJo, Object value, Long linkFormId, Integer linkBusinessType, Integer linkSaasMark) throws XbbException;

    /**
     * 处理系统业务字段
     * @param corpid
     * @param relyFieldEntity
     * @param conditionDTO
     * @param value
     * @return
     * @author xingxing.xiao
     * @date 2020/07/30 17:31
     */
    Object handlerBusinessDataFixedValue(String corpid, FieldAttrEntity relyFieldEntity, ConditionDTO conditionDTO, Object value) throws XbbException;
    /**
     * 处理前置过滤条件的固定值
     * @param thisField
     * @param businessRuleInfoPojo
     * @param filterCondition
     * @return
     * @throws XbbException
     */
    Object handlerPreConditionValue(FieldAttrEntity thisField, BusinessRuleInfoPojo businessRuleInfoPojo, FilterConditionsPoJo filterCondition) throws XbbException;
}
